# user_list = ['hello', 'woniu', 'good']
# pass_list = ['111', '222', '333']
# phone_list = ['', '', '']

user_list = [['hello', '111', '13812345678'], ['woniu', '12345', '18822345634'], ['good', '333', '15822345699']]

# user_list = [{'username':'hello', 'password':'111', 'phone':'13838389438'}, {}, {}]

# 注册
def reg():
    username = input("请输入用户名[注册]：")
    password = input('请输入密码[注册]：')
    phone = input('请输入电话号码[注册]：')

    if check(username) >= 0:
        print("你注册的用户名已经存在.")
    else:
        print("恭喜你，用户名可用.")
        user_info = []
        user_info.append(username)
        user_info.append(password)
        user_info.append(phone)

        user_list.append(user_info)
        print("恭喜你，注册成功.")
        # print(user_list)
        start_menu()

# 登录
def login():
    username = input("请输入用户名[登录]：")
    password = input('请输入密码[登录]：')

    index = check(username)
    if index >= 0:
        if user_list[index][1] == password:
            print("恭喜你，登录成功.")
            main_menu()
        else:
            print("抱歉，密码输入错误.")
    else:
        print("抱歉，登录用户名不存在.")


# 查询
def query():
    print("你的余额为：5000元，电话号码为13812345678.")

# 存款
def deposite():
    print("存款正在运行")

# 取款
def withdraw():
    print("取款正在运行")

# 转账
def transer():
    print("取款正在运行")

# 流水
def history():
    print("流水记录")


# 检查
def check(username):
    for i in range(len(user_list)):
        if user_list[i][0] == username:
            return i

    return -1

    # for user_info in user_list:
    #     if username in user_info:
    #         return user_list.index(user_info)
    # return -1


# 构建开始菜单
def start_menu():
    tip = '''
***************** 欢迎来到WoniuATM **********************
***************** 请选择操作菜单 ************************
************* 1. 注册   2. 登录   3. 退卡 ***************
    '''
    print(tip)
    option = input("请输入你的操作选项：")
    if option == "1":
        reg()
    elif option == "2":
        login()
    else:
        exit('谢谢，欢迎下次光临.')


# 构建登录后业务菜单
def main_menu():
    tip = '''
*************************** 恭喜登录蜗牛银行 **********************************
*************************** 请选择操作菜单 ************************************
****** 1. 查询   2. 取款   3. 存款   4. 转账   5. 流水  6. 返回  7. 退卡 *******
        '''
    print(tip)
    option = input("请输入你的操作选项：")
    if option == "1":
        query()
    elif option == "2":
        withdraw()
    elif option == "3":
        deposite()
    elif option == "4":
        transer()
    elif option == "5":
        history()
    elif option == "6":
        start_menu()
    elif option == "7":
        exit('谢谢，欢迎下次光临.')


start_menu()